﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;
using BLL;
using BLL.UserInfos;
using BLL.UserInfos.DTO;

namespace HomeWork.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserInfoController : ControllerBase
    {
        private readonly IUserInfoBll userInfoBll;

        public UserInfoController(IUserInfoBll userInfoBll)
        {
            this.userInfoBll = userInfoBll;
        }

        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="addUserInfoDto"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult AddUserInfo(AddUserInfoDto addUserInfoDto)
        {
            return Ok(userInfoBll.AddUserInfo(addUserInfoDto));
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="addUserInfoDto"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetLogin(LoginDto loginDto)
        {
            return Ok(userInfoBll.GetLogin(loginDto));
        }
    }
}
